home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1999 May / Cd Pc Users extra 20 mayo 1999.iso / Prog / Inst / FTP / CONNECT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-19  |  2.6 KB  |  83 lines

  1. /* connect.c */
  2.  
  3. #include <windows.h>
  4. #include "connect.h"
  5. #include "message.h"
  6. #include "fce.h"
  7.  
  8. #define MAX_STR   64
  9.  
  10. extern HCURSOR ArrowCursor;      /* arrow cursor */
  11. extern HCURSOR WaitCursor;       /* hour glass cursor */
  12. extern int ConnectStatus;
  13.  
  14. void Message(LPSTR);
  15. void ShowError(int);
  16. int IsConnected(void);
  17.  
  18. static HWND SavedDlg = 0;
  19. static char SrvrString[MAX_STR] = ""; /* FTP server name */
  20. static char UserString[MAX_STR] = ""; /* user login name */
  21. static char PassString[MAX_STR] = ""; /* user login password */
  22.  
  23. ///EnableWindow(GetDlgItem(hDlg,ID_STOP_BTN), EnableFlag);
  24.  
  25. #ifdef WIN32
  26. BOOL CALLBACK
  27. #else
  28. BOOL FAR PASCAL
  29. #endif
  30. ConnectDlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
  31. {int Code;
  32.  static char Temp[100];
  33.  
  34.  switch (iMsg)
  35.     {case WM_INITDIALOG:
  36.         SavedDlg = hDlg;
  37. #if 1        
  38.         SetDlgItemText(hDlg, ID_SRVR_BOX, (LPSTR)"ftp.marshallsoft.com"); 
  39.         SetDlgItemText(hDlg, ID_USER_BOX, (LPSTR)"anonymous"); 
  40.         SetDlgItemText(hDlg, ID_PASS_BOX, (LPSTR)"msc@traveller.com");  
  41. #else
  42.         SetDlgItemText(hDlg, ID_SRVR_BOX, (LPSTR)"10.0.0.1"); 
  43.         SetDlgItemText(hDlg, ID_USER_BOX, (LPSTR)"mike"); 
  44.         SetDlgItemText(hDlg, ID_PASS_BOX, (LPSTR)"mike");
  45. #endif
  46.         SetCursor(ArrowCursor);
  47.         EnableWindow(GetDlgItem(hDlg,ID_CONN_BTN), 1);
  48.         return TRUE;
  49.  
  50.       case WM_COMMAND :
  51.         switch (LOWORD(wParam))
  52.          { 
  53.           case ID_CONN_BTN:
  54.             GetDlgItemText(hDlg, ID_SRVR_BOX, (LPSTR)SrvrString, MAX_STR);
  55.             GetDlgItemText(hDlg, ID_USER_BOX, (LPSTR)UserString, MAX_STR);
  56.             GetDlgItemText(hDlg, ID_PASS_BOX, (LPSTR)PassString, MAX_STR);              
  57.             SetCursor(WaitCursor);
  58.             /* define LOG file */
  59.             fceSetString(0,FCE_SET_LOG_FILE,(LPSTR)"winftp.log"); 
  60.             EnableWindow(GetDlgItem(hDlg,ID_CONN_BTN), 0);
  61.             /* connect to server */            
  62.             Code = fceConnect(0,(LPSTR)SrvrString,(LPSTR)UserString,(LPSTR)PassString);
  63.             if(Code<0)
  64.               {ConnectStatus = FALSE;
  65.                ShowError(Code);
  66.               }
  67.             else
  68.               {ConnectStatus = TRUE;
  69.                wsprintf((LPSTR)Temp,"Connected to %s",(LPSTR)SrvrString);
  70.                Message((LPSTR)Temp);
  71.               }
  72.              EndDialog(hDlg, 0);
  73.              return TRUE;  
  74.           case ID_EXIT_BTN:
  75.              EndDialog(hDlg, 0);
  76.              return TRUE;  
  77.          }
  78.          break;
  79.     }
  80.     return (FALSE);
  81. } /* end ConnectDlgProc */
  82.                        
  83.